<html>
<head>
    <title>Print Invoice</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <input id="btnPrint" type="button" value="Print View" onclick=preview(1) />
    <script>
    function preview(oper){
        if (oper < 10){
            bdhtml=window.document.body.innerHTML;//获取当前页的html代码
            sprnstr="<!--startprint"+oper+"-->";//设置打印开始区域
            eprnstr="<!--endprint"+oper+"-->";//设置打印结束区域
            prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html

            prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
            window.document.body.innerHTML=prnhtml;
            window.print();
            window.document.body.innerHTML=bdhtml;
        } else {
            window.print();
        }
    }
    </script>
    <!--startprint1-->
    <style>
        #table1 td{text-align:center;color:#000000;}
        #table3 {border:none;}
        #table3 th{height:30px;border-right:1px solid #fff;border-bottom:1px solid #3E312B;border-right:1px solid #3E312B;border-top:2px solid #3E312B;}
        #table3 td{text-align:center;color:#000000;border-bottom:1px solid #3E312B;border-right:1px solid #3E312B;}
        #table4 td{font-size:14px;font-weight:200;}
    </style>
    <div style="width:595px;height:842px;margin:10px auto;">
        <table style="width:100%;height:70px;margin:auto;" id="table1">
            <tr>
                <td style="width:50%">
                    <div style="display:inline-block;vertical-align:middle;text-align:left;">
                        <label style="font-size:20px;font-weight:bold;"><?=$selfinfo['name']?></label><br>
                        <label style="font-size:14px;"><?=$selfinfo['address']?></label><br>
                    </div>
                </td>
                <td style="width:50%">
                    <label style="font-size:20px;font-weight:bold;">Invoice</label><br>
                    <label style="font-size:14px;font-weight:bold;">INVOICE NO:</label>
                    <label style="font-size:14px;font-weight:bold;color:red;"><?=$invoice['no']?></label><br>
                    <label style="font-size:14px;font-weight:bold;">DATE:</label>
                    <label style="font-size:14px;font-weight:bold;color:red;"><?=$invoice['invoicedate']?></label>
                </td>
            </tr>
        </table>
        <table style="width:70%;height:70px;margin:auto;" id="table2">
            <tr>
                <td style="text-align:right;">
                    <label style="font-size:12px;font-weight:bold;">Bill To:</label>
                    <label style="font-size:12px;font-weight:normal;"><?=$invoice['client']?></label>
                </td>
            </tr>
        </table>
        <table style="width:100%;margin:auto;" id="table3" cellspacing="0" cellPadding="0">
            <tr>
                <th style="width:16%;border-left:1px solid #3E312B;">SALESPERSON</th>
                <th style="width:16%;">CONTACT</th>
                <th>DATE SHIPPED</th>
                <th style="width:16%;">SHIPPED VIA</th>
                <th style="width:16%;">F.O.B. POINT</th>
                <th style="width:16%;">TERMS</th>
            </tr>
            <tr>
                <td style="border-left:1px solid #3E312B;"><?=$invoice['salersperson']?></td>
                <td><?=$invoice['contact']?></td>
                <td><?=$invoice['shippeddate']?></td>
                <td>NA</td>
                <td>NA</td>
                <td></td>
            </tr>
        </table><br>
        <table style="width:100%;margin:auto;" id="table3" cellspacing="0" cellPadding="0">
            <tr>
                <th style="width:12%;border-left:1px solid #3E312B;">QUANTITY</th>
                <th style="border-right:none;">LINE</th>
                <th style="border-right:none;">RELEASE/DELIVERY</th>
                <th style="border-right:none;">DESCRIPTION</th>
                <th>P/N</th>
                <th>UNIT PRICE</th>
                <th style="width:12%;">AMOUNT</th>
            </tr>
            <tr>
                <td style="border-left:1px solid #3E312B;height:100px;"></td>
                <td colspan="4"><?=$invoice['content']?></td>
                <td><?=$invoice['unitprice']?></td>
                <td><?=$invoice['amountprice']?></td>
            </tr> 
            <tr>
                <td style="border:none;text-align:right;border-right:1px solid #3E312B;font-weight:bold;height:40px;" colspan="6">SUBTOTAL:</td>
                <td><?=$invoice['subtotal']?></td>
            </tr> 
            <tr>
                <td style="border:none;text-align:right;border-right:1px solid #3E312B;font-weight:bold;height:40px;" colspan="6">SUBTOTAL:</td>
                <td><?=$invoice['totaldue']?></td>
            </tr>
        </table>
        <table style="width:100%;margin:auto;" id="table4">
            <tr>
                <td style="font-size:10px;">Invoice is in SGD.</td>
            </tr>
            <tr>
                <td style="font-size:10px;">
                    Please note: CMOS Consulting is a business entity & is not registered for GST.
                    <span style="display:inline-block;width:130px;height:20px;border-bottom:1px solid #000000;"></span>
                </td>
            </tr>
            <tr>
                <td>Note:<span style="display:inline-block;float:right;">Siganature and date</span></td>
            </tr>
            <tr>
                <td>Cheque should be crossed and made payable to <?=$selfinfo['info']?></td>
            </tr>
            <tr>
                <td>For Electronic Funds Transfers:</td>
            </tr>
            <tr>
                <td>Banking Details:<?=$selfinfo['bankaccount']?></td>
            </tr>
            <tr>
                <td>(with Premier Banking centre)</td>
            </tr>
            <tr>
                <td>Beneficiary's Name:</td>
            </tr>
            <tr>
                <td>Bank Name:</td>
            </tr>
            <tr>
                <td>Branch No:</td>
            </tr>
            <tr>
                <td>Account No:</td>
            </tr>
        </table>
    </div>
    <!--endprint1-->
</body>
</html>